{include file="public/public"}
<style>
	.clear_a {
		color: #EFA538;
	}
	
	.editsym,
	.editval {
		cursor: pointer;
	}
	
	.clear_a:link {
		color: #EFA538;
	}
	
	.clear_a:visited {
		color: #EFA538;
	}
	
	.clear_a:hover {
		color: #1987E7;
	}
	
	.clear_a:active {
		color: #EFA538;
	}
</style>
<script>
	function clearbykey(key) {
		$.post('__APP__/admin/clearDefaultOper', {
			'key': key
		}, function(data) {
			if(data.result) {
				window.location.reload();
			} else {
				alert(data.msg);
				return false;
			}
		}, "json");
	}
</script>
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
	<div class="layui-body layui-tab-content site-demo site-demo-body">
		<div class="layui-tab-item layui-show">
			<div class="layui-main">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
				</fieldset>
				<span class="layui-breadcrumb">
                    <a href="__APP__/{$menuConfigArry['functionMod']}/{$menuConfigArry['menuLabel']}">{$menuConfigArry['pmenuName']}</a>
                    <a><cite>{$menuConfigArry['menuName']}</cite></a>
                </span>
				<hr>
				<div class="content_3 left">
					<div class="content_3_wz"><img src="__PUBLIC__/images/dajt.png">系统管理 > 默认报警值</div>
					<div class="content_3_ss clear">
						<?php
						  	if($noticeArr){
						?>
							<p style='text-align:center'>设置默认报警值</p>
							<table class="content_bg layui-table" cellpadding="0" border="0" style='margin-top:10px;'>
								<thead>
									<tr>
										<td>参数名</td>
										<td>符号</td>
										<td>默认值(只支持数字)</td>
										<td>操作</td>
									</tr>
								</thead>
								<?php
									foreach($noticeArr as $key=>$value){
									switch($value[0]){
									case 1:
										$symbol = '>=';
										break;
									case 2:
										$symbol = '<=';
										break;
									default:
										$symbol = '';
										break;
									}
								?>
									<tr>
										<td>{$key}</td>
										<td>
											<a style='color:#4e4e4e' class="symbolval<?php if(!$symbol)echo ' editsym';?>" key='{$key}' symbol={$value[0]}>{$symbol}</a>
										</td>
										<td>
											<a style='color:#4e4e4e' class='editval' key='{$key}'>{$value[1]}</a>
										</td>
										<td>
											<a href='#' class='clear_a' onclick='clearbykey("{$key}")'>清空</a>
										</td>
									</tr>
								<?php
									}
								?>
							</table>
						<?php
							}else{
						?>
							<p>暂时无法设置报警值</p>
							<p>请联系管理员</p>
						<?php
							}
					  	?>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/bootstrap3-editable-1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script>
	$(function() {
		$('.editval').editable({
			type: "text", //编辑框的类型。支持text|textarea|select|date|checklist等
			title: "默认值", //编辑框的标题
			disabled: false, //是否禁用编辑
			emptytext: "未设置", //空值的默认文本
			mode: "inline", //编辑框的模式：支持popup和inline两种模式，默认是popup
			validate: function(value) { //字段验证
				var r1 = /^\d+(\.\d+)?$/;
				var r2 = /^\d+$/;
				var number = $.trim(value);
				if(!number) {
					return '不能为空';
				}
				if(!r1.test(value) && !r2.test(value)) {
					return '数据只支持数字或小数,百分号请先转换成小数';
				}
				var key = $(this).attr('key');
				var symbol = $(".symbolval[key='" + key + "']").attr('symbol');
				if(!symbol) {
					return '请先选择符号';
				}
				$.post('__APP__/admin/addDefaultOper', {
					'key': key,
					'symbol': symbol,
					'number': number
				}, function(data) {
					if(data.result) {
						alert('修改成功');
						window.location.reload();
					} else {
						alert(data.msg);
						return false;
					}
				}, 'json');

			}
		});
		$('.editsym').editable({  
			type: "select",
			    //编辑框的类型。支持text|textarea|select|date|checklist等
			  source: [{
				value: 1,
				text: ">="
			}, {
				value: 2,
				text: "<="
			}],
			  title: "选择符号",
			   //编辑框的标题
			  disabled: false,
			   //是否禁用编辑
			  emptytext: "未设置",
			  //空值的默认文本
			  mode: "inline",
			   //编辑框的模式：支持popup和inline两种模式，默认是popup
			  validate: function(value) { //字段验证
				   
				if(!$.trim(value)) {    
					return '不能为空';   
				}
				$(this).attr('symbol', value);  
			} 
		});

	});
</script>